package com.yp.infrastructure.common.annotation;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.annotation.AliasFor;

import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;

/**
 * 启动阶段的延迟加载， 将两个Annotation合并为一个
 * 1. Lazy: {@link Lazy}
 * 2. Autowired: {@link Autowired}
 */
@Lazy
@Autowired
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({FIELD})
public @interface LazyAutowired {

    @AliasFor(annotation = Lazy.class)
    boolean value() default true;

    @AliasFor(annotation = Autowired.class)
    boolean required() default true;

}
